from sqlalchemy import Column, Integer, String, DateTime, Numeric, Boolean, Text
from sqlalchemy.sql import func
from app.core.database import Base

class PriceRule(Base):
    __tablename__ = "price_rules"
    
    id = Column(Integer, primary_key=True, index=True)
    apartment_type = Column(String(10), nullable=False, index=True)
    area_min = Column(Numeric(10, 2), nullable=False)
    area_max = Column(Numeric(10, 2), nullable=False)
    unit_price = Column(Numeric(10, 2), nullable=False)
    description = Column(Text, nullable=True)
    is_active = Column(Boolean, default=True, nullable=False)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())

